package com.welink.cmp.adapter.api.metadata.query;

import com.welink.cmp.dto.metadata.MetadataIdListQry;
import com.welink.cmp.dto.metadata.MetadataIdQry;
import com.welink.cmp.dto.metadata.vpc.VpcCO;
import com.welink.cmp.dto.metadata.vpc.VpcListByPageQry;
import com.welink.cmp.meatdata.service.VpcAppService;
import com.welink.common.dto.MultiResponse;
import com.welink.common.dto.PageResponse;
import com.welink.common.dto.SingleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * VPC查询服务API
 *
 * @create
 */
@RestController("/api/vpc/query")
public class VpcQueryServiceApi {

    @Autowired
    private VpcAppService vpcAppService;

    /**
     * [ID查询]查询VPC信息详情
     * @param idQry 主键ID
     * @return VPC DTO
     */
    @GetMapping("/vpc-item")
    public SingleResponse<VpcCO> queryVpcById(@RequestBody MetadataIdQry idQry){
        VpcCO dto = vpcAppService.getVpcById(idQry.getId());
        return SingleResponse.of(dto);
    }

    /**
     * [列表查询]列表查询VPC信息
     * @param listQuery 列表查询指令
     * @return VPC DTO列表
     */
    @GetMapping("/vpc-list")
    public MultiResponse<VpcCO> listQueryVpc(@RequestBody MetadataIdListQry listQuery){
        List<VpcCO> list = vpcAppService.vpcListQuery(listQuery);
        return MultiResponse.of(list);
    }

    /**
     * [分页查询]分页查询VPC信息
     * @param pageQry 分页查询指令
     * @return VPC DTO分页结果
     */
    @GetMapping("/vpc-page")
    public PageResponse<VpcCO> pageQueryVpc(@RequestBody VpcListByPageQry pageQry){
        return vpcAppService.vpcPageQuery(pageQry);
    }
}
